/**
 * Copyright 2008-2009 HAN.BIFANG
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package han.bashe.common.schema;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

import v1.query.web.bifang.han.QosDocument.Qos;
import v1.query.web.bifang.han.ServiceDocument.Service;
import v1.query.web.bifang.han.VersionDocument.Version;

/**
 * @Author Kent
 */
public class ServiceInfoWrapper implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Service service;
	
	private HashMap<String,Version> versions = new HashMap<String, Version>();
	
	private HashMap<String ,String> serviceQos = new HashMap<String, String>();
	
	private HashMap<String ,HashMap<String,String>> vQos = new HashMap<String, HashMap<String,String>>();
	
	private HashMap<String ,String> methods = new HashMap<String, String>();
	
	public ServiceInfoWrapper(Service ser){
		this.service = ser;
		
		List<Qos> tmp =   ser.getQosList();
		for(Qos q : tmp){
			serviceQos.put(q.getName(), q.getValue());
		}
		List<Version> vl = service.getVersionList();
		for(Version v : vl){
			versions.put(v.getVersion(), v);
			HashMap<String, String> vq = new HashMap<String, String>();
			tmp = v.getQosList();
			for(Qos q : tmp){
				vq.put(q.getName(), q.getValue());
			}
			vQos.put(v.getVersion(), vq);
			
			
		}
	}
	
	public Version getVersion(String version){
		return versions.get(version);
	}
	
	public Version getDefaultVersion(){
		String version = service.getDefaultVersion();
		return versions.get(version);
	}
	public Service getService(){
		return service;
	}
	
	public HashMap<String, String> getServiceQos(){
		return serviceQos;
	}
	
	public HashMap<String, String> getVersionQos(String version){
		return vQos.get(version);
	}

	

}
